package com.bonc.ioc.demo.contorller;

import com.bonc.ioc.demo.dao.TeacherMapper;
import com.bonc.ioc.demo.entity.Teacher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/teacher")

public class TeacherController {
    @Autowired
    private TeacherMapper teacherMapper;

    /**
     * description:依据删除教师信息
     * date: 2020/12/31 16:04
     * author: czq
     * @return void
     */
    
    @RequestMapping("/add")
    public void add() {
        Teacher teacher = new Teacher();
        teacher.setId(11);
        teacher.setName("zhangsa");
        teacherMapper.insert(teacher);
    }

    @RequestMapping("/deleteById")
    public void deleteById(int id) {
        teacherMapper.deleteById(id);
    }

    @RequestMapping("/insert")
    public void insert(@RequestParam("id") Integer id, @RequestParam("name")  String name) {
            Teacher teacher = new Teacher();
            teacher.setId(id);
            teacher.setName(name);
            teacherMapper.insert(teacher);
    }
}
